﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BLL;

namespace EDM
{
    public class RoleQuery : IRoleSearch
    {
        public List<BLL.Role> Search(string roleName, string firstName, string lastName, string status, string authorities, string sortExpression, string sortDirection, int PageSize, int PageIndex, out int pageCnt)
        {


            List<BLL.Role> roleList = new List<BLL.Role>();
            TrainingWorkshopEntities db = new TrainingWorkshopEntities();
            pageCnt = 0;

            List<View_RoleInfo> roleDetails = db.rolesearchprocedure3(roleName, firstName, lastName, status, authorities, sortExpression, sortDirection, PageSize, PageIndex).ToList<View_RoleInfo>();

            if (roleDetails != null)
            {                

                foreach (var r in roleDetails)
                {
                    BLL.Role singleRole = new BLL.Role();
                    singleRole.RId = r.rid;
                    singleRole.RoName = r.roname;
                    singleRole.AuName = r.auname;
                    singleRole.LeName = r.lename;
                    pageCnt = r.pageCnt;

                    roleList.Add(singleRole);
                }
            }
               
                               


           

            return roleList;

         

    }

        }
    }

